package com.yunhe.policyfulfillment.authority.service.impl;

import com.yunhe.policyfulfillment.authority.domain.PolicyMenu;
import com.yunhe.policyfulfillment.authority.domain.PolicyRoleAndMenuRelation;
import com.yunhe.policyfulfillment.authority.repository.PolicyRoleAndMenuRelationRepository;
import com.yunhe.policyfulfillment.authority.service.PolicyRoleAndMenuRelationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhengbo
 * @date 2021/9/19 9:04
 */

@Service
@Slf4j
public class PolicyRoleAndMenuRelationServiceImpl implements PolicyRoleAndMenuRelationService {

    @Autowired
    private PolicyRoleAndMenuRelationRepository policyRoleAndMenuRelationRepository;

    @Override
    public int createPolicyRoleAndMenuRelationSelective(PolicyRoleAndMenuRelation policyRoleAndMenuRelation) {
        return policyRoleAndMenuRelationRepository.createPolicyRoleAndMenuRelationSelective(policyRoleAndMenuRelation);
    }

    @Override
    public void deletePolicyMenusByRoleId(Long roleId) {
        policyRoleAndMenuRelationRepository.deletePolicyMenusByRoleId(roleId);
    }

    @Override
    public void deletePolicyMenusByMenuId(Long menuId) {
        policyRoleAndMenuRelationRepository.deletePolicyMenusByMenuId(menuId);
    }

    @Override
    public List<PolicyMenu> searchPolicyMenusByRoleId(Long roleId) {
        return policyRoleAndMenuRelationRepository.searchPolicyMenusByRoleId(roleId);
    }
}
